package com.huayi.website.controller.manage;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;

@RequestMapping("/manage")
@Controller
public class MArticleController {
    /**
     * 列表
     *
     * @return
     */
    @RequestMapping(value = "/article_list", method = RequestMethod.GET)
    public String getList(HttpServletRequest request, Model model) {
        Integer type = null;
        Integer pageIndex = 1, pageSize = 10;
        if (!StringUtils.isEmpty(request.getParameter("page"))) {
            pageIndex = Integer.parseInt(request.getParameter("page"));
        }
        if (!StringUtils.isEmpty(request.getParameter("type"))) {
            type = Integer.parseInt(request.getParameter("type"));
            model.addAttribute("type",type);
        }


        model.addAttribute("pageIndex", pageIndex);
        model.addAttribute("pageSize", pageSize);
//        PagingResponse<BannersEntity> result = bannersService.getBannerList(pageIndex, pageSize, 0, "HT", "0");
        model.addAttribute("list", null);
        model.addAttribute("totalSize", 0);

        model.addAttribute("menu","article_list");
        return "manage/article_list";
    }

    @RequestMapping(value = "/article_add", method = RequestMethod.GET)
    public String add(HttpServletRequest request, Model model) {
        Integer type = null;
        if (!StringUtils.isEmpty(request.getParameter("type"))) {
            type = Integer.parseInt(request.getParameter("type"));
            model.addAttribute("type",type);
        }


        model.addAttribute("menu","article_list");
        return "news_add";
    }

}
